<?php
namespace app;

use app\BaseController;
use think\facade\Db;

class Basic extends BaseController
{

    public $auth_url = null;
    public $param = [];

    function initialize()
    {
        $this->param = $this->request->param();
        if(empty($this->param['limit'])){
            $this->param['limit']=null;
        }
        $module     = strtolower(app('http')->getName());
        $controller = ($this->request->controller());
        $action     =  strtolower($this->request->action());
        $this->auth_url=$module . '/' . $controller . '/' . $action;
    }

    public function error( $msg = '请求成功',$data=[]){
        return $this->ajax_return(0,$msg,$data);
    }
    public function success( $msg = '请求成功',$data=[])
    {
        return $this->ajax_return(1,$msg,$data);
    }
    public function ajax_return( $code, $msg = '请求成功',$data=[])
    {
        $result = [
            'code' => $code,
            'msg'  => $msg,
            'requestParam' => $this->request->param(),
        ];
        return json(array_merge($result,$data));
    }


}
